package com.ruoyi.controller;

import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.domain.ZhwyAdvancedeposit;
import com.ruoyi.domain.ZhwyDefaultcharges;
import com.ruoyi.service.ZhwyDefaultchargesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.List;

/**
 * ClassName ZhwyDefaultchargesController
 * Description TODO
 * Author JunEr
 * Date 2024年05月08日 16:15
 * Version 1.0
 */
@RestController

@RequestMapping("/zxwy/DefaultCharge")
public class ZhwyDefaultchargesController extends BaseController {
    @Autowired
    ZhwyDefaultchargesService service;
    @GetMapping("/save/{ids}")
    @Anonymous
    public AjaxResult add(@PathVariable("ids") Long[] ids) {
        // System.out.println(Arrays.toString(ids));
        for (Long id : ids) {
            ZhwyDefaultcharges defaultcharges = new ZhwyDefaultcharges();
            defaultcharges.setChargeItemId(id);
            service.saveDefaultCharge(defaultcharges);
        }

        return AjaxResult.success();
    }
    @GetMapping("/savecs/{ids}")
    @Anonymous
    public AjaxResult addcs(@PathVariable("ids") Long[] ids) {
        // System.out.println(Arrays.toString(ids));
        for (Long id : ids) {
            ZhwyDefaultcharges defaultcharges = new ZhwyDefaultcharges();
            defaultcharges.setChargeItemId(id);
            service.saveDefaultChargecs(defaultcharges);
        }

        return AjaxResult.success();
    }

    @DeleteMapping("/remove/{id}")
    @Anonymous
    public AjaxResult remove(@PathVariable Long id) {
        return toAjax(service.deleteDefaultChargeById(id));
    }
    @DeleteMapping("/removecs/{id}")
    @Anonymous
    public AjaxResult removecs(@PathVariable Long id) {
        return toAjax(service.deleteDefaultChargeByIdcs(id));
    }
}
